#include<bits/stdc++.h>
using namespace std;
int b[10005];
int c[10005];
void solve(){
	int n,m,k;
	cin >> n >> m >> k;
	for(int i = 1;i <= n;i++){
		cin >> b[i];
	}
	for(int i = 1;i <= m;i++){
		cin >> c[i];
	}
	int ans = 0;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++){
			if(b[i] + c[j] <= k) ans++;
		}
	}
	cout << ans << "\n";
}
int main(){
	int t;
	cin >> t;
	while(t--) solve();
}